home *** CD-ROM | disk | FTP | other *** search
- /* testio.c - test viewio.c */
- #include "stdio.h"
- #include "cminor.h"
- #include "viewparm.h"
-
- extern FILE *fp ;
- extern long filesize ;
- long ftell() ;
- long where_now() ;
-
- main()
- {
- long pos ;
- int c , i ;
- char fn[65] ;
-
- printf("\n testing I/O module\n") ;
-
- printf("\n file name:") ;
- scanf("%s",fn) ;
- printf("\n open_file = %d ",open_file(fn) ) ;
- printf("\n fp = %x ",fp) ;
-
- printf("\n\n calling set_filesize") ;
- filesize = -1L ;
- set_filesize(ASC_MODE) ;
- printf("\n filesize = %1d \n",filesize) ;
-
- pos = 3 ;
- printf("\n move)to %1d",pos) ;
- mone_to(pos) ;
- printf("\n where_now = %1d next char is %d ftell = %1d\n",
- where_now() , get_next_char() , ftell(fp) ) ;
- pos = 1 ;
- move_to(pos) ;
- printf("\n move_to %1d",pos) ;
- printf("\n where_now = 1d next char is %d ftell = %1d\n",
- where_now(), get_next_char(), ftell(fp) ) ;
-
-
- scanf("%c%c",&c,&c) ; /* pause here */
-
-
- /* test get_next_char */
- move_to(0L) ; /* start at beginning of file */
- printf("\n test get next char - sequintial reads \n ") ;
- c = get_next_char() ;
- i = 0 ;
- while( c != EOF_MARK )
- { printf(" c=%d ",c) ;
- c = get_next_char() ;
- i = i+1 ;
- if( i > 100 )
- break ;
- }
-
- printf("\n EOF reached - c=%d \n",c) ;
- scanf("%c%c",&c,&c) ; /* pause here */
-
-
-
- move_to(filesize) ; /* start at end of file */
- printf("\n test get_next_char at eof \n") ;
- for( i=0 ; i < 10 ; i=i =i+1 )
- { printf(" c=%d ",get_next_char() ) ; }
- printf("\n thru \n") ;
- scanf("%c%c",&c,&c) ; /* pause here */
-
- /* test get previous char */
- printf("\n test get_previous_char \n") ;
- i = 0 ;
- c = get_previous_char() ;
- while ( c != BOF_MARK )
- { printf(" c=%d ",c) ;
- c = get_previous_char() ;
- i = i+1 ;
- if( i > 100 )
- break ;
- }
- printf("\n BOF reached - c+%d \n",c) ;
- scanf("%c%c ",&c,&c) ; /* pause here */
-
-
- move_to(0L) ;
- printf("\n test get_previous_char at BOF \n") ;
- for( i=0 ; i < 10 ; i = i+1 )
- { printf(" c=%d ",getprevious_char() ) ; }
- printf("\n thru \n") ;
-
- close_file() ;
- }
-
-
-